package org.wzl._360mallbackend.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wzl._360mallbackend.entity.Category;
import org.wzl._360mallbackend.service.CategoryService;
import org.wzl._360mallbackend.utils.Response;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/getDeepAllById")
    public Response getAll(Integer id) {
        List<Category> allCategoryById = categoryService.getAllCategoryById(id);
        return Response.ok().putData("category" , allCategoryById);
    }

    @GetMapping("/getCommodityByCategoryName")
    public Response getCommodityByCategoryName(String categoryName) {
        Map<String,Object> map = categoryService.getCommodityByCategoryName(categoryName);
        return Response.ok().putData("categoryAndCommodity" , map);
    }

}
